package com.lzxuni.modules.disease.service.impl;

import com.lzxuni.modules.common.entity.PageParameter;
import com.lzxuni.modules.disease.entity.DiseaseCritical;
import com.lzxuni.modules.disease.mapper.DiseaseCriticalMapper;
import com.lzxuni.modules.disease.service.DiseaseCriticalService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
import com.lzxuni.common.utils.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * <p>
 * 病情管理--病情状态临界值 服务实现类
 * </p>
 *
 * @author gyl
 * @since 2020-12-02
 */
@Service
public class DiseaseCriticalServiceImpl extends ServiceImpl<DiseaseCriticalMapper, DiseaseCritical> implements DiseaseCriticalService {

        @Override
        public PageInfo<DiseaseCritical> queryPage(PageParameter pageParameter, DiseaseCritical diseaseCritical) {
            if (StringUtils.isNotEmpty(pageParameter.getSidx())) {
                PageHelper.startPage(pageParameter.getPage(), pageParameter.getRows()).setOrderBy(
                pageParameter.getSidx() + " " + pageParameter.getSord());
            } else {
                PageHelper.startPage(pageParameter.getPage(), pageParameter.getRows());
            }
            List<DiseaseCritical> diseaseCriticalList = baseMapper.queryList(diseaseCritical);
            PageInfo<DiseaseCritical> pageInfo = new PageInfo<>(diseaseCriticalList);
            return pageInfo;
        }

        @Override
        public List<DiseaseCritical> queryList(DiseaseCritical diseaseCritical) {
            List<DiseaseCritical> diseaseCriticalList = baseMapper.queryList(diseaseCritical);
            return diseaseCriticalList;
        }


    @Override
    public boolean isNotHave(DiseaseCritical diseaseCritical) {   //条件 精确的病害名称 作物型号id 上下 月份 上下 数值
        List<DiseaseCritical> diseaseCriticalList = baseMapper.queryList(diseaseCritical);
        if(diseaseCriticalList.isEmpty()){
            return true ;
        }else{
            return false;
        }

    }


}
